/**1/1 -1/2 +1/3 -....+1/99-1/100
 * @author yuisama
 * @date 2022/03/21 16:56
 **/
public class MathQuzi {
    public static void main(String[] args) {
        int a =1;
        double sum =0.0;
        for (int i = 1; i <=100; i++) {
//          sum += 1/i*a;
            //运行结果错误，因为类型不一致，需要转换类型
            sum += 1.0/i *a;
            a = -a;
        }
        System.out.println(sum);
    }
}
